from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from rest_framework.views import APIView

from blog.article.views import Result


class UserLogin(APIView):
    # permission_classes = []  # 显式允许所有请求
    # authentication_classes = []  # 禁用所有认证类

    """用户登录"""

    # @csrf_exempt  # 双重保险
    def post(self, request):
        print("/user/login/ post请求")
        #打印出request.post数据
        print("打印出request.POST数据：",request.data)
        #打印出头部信息
        print("打印出request.headers数据：",request.headers)
        #组装返回结果
        result = Result(200,"success",request.data)
        #返回json数据
        return Response(result.to_json(),200)